package org.sport.logic;

import org.sport.dbInterface.SpoHisOperation;
import org.sport.dbInterface.UserInfoHisOperation;
import org.sport.init.SportClientSymbol;
import org.sport.init.SportServerSymbol;
import org.sport.model.entityModel.DateInfo;
import org.sport.model.entityModel.SporthistorytableEntity;
import org.sport.model.entityModel.UserinfohistorytableEntity;
import org.sport.model.jsonModel.Json_1_calorie;
import org.sport.model.jsonModel.Json_1_kilometre;
import org.sport.model.jsonModel.Json_1_walkNum;
import org.sport.model.jsonModel.Json_1_weight;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by zehong
 *
 * 分析页面（首页）的逻辑处理，从数据库中取出数据，准备好后返回给用户
 * 主要给用户提供步数，卡路里，体重，运动公里等数据
 */

@Service
public class Logic_Homepage {

    @Autowired
    SpoHisOperation spoHisOperation;

    @Autowired
    LogicUtils logicUtils;

    @Autowired
    UserInfoHisOperation userInfoHisOperation;

    private ArrayList<Integer> day0=new ArrayList<>();
    private ArrayList<Integer> day1=new ArrayList<>();
    private ArrayList<Integer> day2=new ArrayList<>();
    private ArrayList<Integer> day3=new ArrayList<>();
    private ArrayList<Integer> day4=new ArrayList<>();
    private ArrayList<Integer> day5=new ArrayList<>();
    private ArrayList<Integer> day6=new ArrayList<>();


    //步数的历史数据
    public Json_1_walkNum walkNum(Json_1_walkNum json_1_walkNum){

        System.out.println("进入Logic-1-walkNum");

        //在运动历史表中先找出该用户所有的运动历史记录
        List<SporthistorytableEntity> userSportAllList=spoHisOperation.findSpoHisByUserId(logicUtils.findUser(json_1_walkNum.getPhoneNumber()));

        //找出步行或者跑步的记录
        List<SporthistorytableEntity> userWalkOrRunList= new ArrayList<>();
        if (userSportAllList==null){
            //用户一条运动记录都没有
        }else {
            for (int i=0;i<userSportAllList.size();i++){
                if (userSportAllList.get(i).getSpoType().equals(SportServerSymbol.sporthistorytable.SPOTYPE_WALK)){
                    userWalkOrRunList.add(userSportAllList.get(i));
                } else if (userSportAllList.get(i).getSpoType().equals(SportServerSymbol.sporthistorytable.SPOTYPE_RUN)){
                    userWalkOrRunList.add(userSportAllList.get(i));
                }
            }
        }

        //先判断该用户有没有步行或者跑步的记录
        if(userWalkOrRunList.size()==0){
            //没有记录，用户步数为0
            System.out.println("找不到跑步，步行记录");
            json_1_walkNum.setAveWalkNum(0);
            json_1_walkNum.setTotWalkNum(0);
            json_1_walkNum.setWalkNum0(0);
            json_1_walkNum.setWalkNum1(0);
            json_1_walkNum.setWalkNum2(0);
            json_1_walkNum.setWalkNum3(0);
            json_1_walkNum.setWalkNum4(0);
            json_1_walkNum.setWalkNum5(0);
            json_1_walkNum.setWalkNum6(0);
            json_1_walkNum.setResult(SportClientSymbol.Homepage.WALKNUM_RESULT_SUCCESS_NULL);
        }else {
            //有记录就要计算出来各种步数的数据
            System.out.println("找到跑步，步行记录，一共有"+userWalkOrRunList.size()+"条记录");

            //得到一周的时间，方便后续进行判断是哪一天的步数
            DateInfo dateInfo=logicUtils.getWeekDateInfo();
            //先分好组，找到所有记录在最近一周的分布情况
            day0.clear();
            day1.clear();
            day2.clear();
            day3.clear();
            day4.clear();
            day5.clear();
            day6.clear();
            for (int temp=0;temp<userWalkOrRunList.size();temp++){
                System.out.println(userWalkOrRunList.get(temp).getId());
                //在今天內的归为今天，类似在那个时间段內的归为哪一天
                Timestamp timestamp=userWalkOrRunList.get(temp).getStartTiem();
                if (timestamp.after(dateInfo.getToday_begin())&&timestamp.before(dateInfo.getToday_end())){
                    day0.add(temp);
                }else if (timestamp.after(dateInfo.getTodayBefore1_begin())&&timestamp.before(dateInfo.getTodayBefore1_end())){
                    day1.add(temp);
                }else if (timestamp.after(dateInfo.getTodayBefore2_begin())&&timestamp.before(dateInfo.getTodayBefore2_end())){
                    day2.add(temp);
                }else if (timestamp.after(dateInfo.getTodayBefore3_begin())&&timestamp.before(dateInfo.getTodayBefore3_end())){
                    day3.add(temp);
                }else if (timestamp.after(dateInfo.getTodayBefore4_begin())&&timestamp.before(dateInfo.getTodayBefore4_end())){
                    day4.add(temp);
                }else if (timestamp.after(dateInfo.getTodayBefore5_begin())&&timestamp.before(dateInfo.getTodayBefore5_end())){
                    day5.add(temp);
                }else if (timestamp.after(dateInfo.getTodayBefore6_begin())&&timestamp.before(dateInfo.getTodayBefore6_end())){
                    day6.add(temp);
                }
            }


            //得到总步数
            int totalWalkNum=0;
            for (int j=0;j<userWalkOrRunList.size();j++){
                totalWalkNum+=userWalkOrRunList.get(j).getStepNumer();
            }

            //得到平均步数
            int aveWalkNum=(int)(totalWalkNum/userWalkOrRunList.size());

            //得到今天的步数
            int walkNum0=0;
            if (day0.size()!=0){
                System.out.println("今天有："+day0.size());
                for (int temp=0;temp<day0.size();temp++){
                    walkNum0+=userWalkOrRunList.get(day0.get(temp)).getStepNumer();
                }
            }

            //得到1天前的步数
            int walkNum1=0;
            if (day1.size()!=0){
                System.out.println("1天前有："+day1.size());
                for (int temp=0;temp<day1.size();temp++){
                    walkNum1+=userWalkOrRunList.get(day1.get(temp)).getStepNumer();
                }
            }

            //得到2天前的步数
            int walkNum2=0;
            if (day2.size()!=0){
                System.out.println("2天前有："+day2.size());
                for (int temp=0;temp<day2.size();temp++){
                    walkNum2+=userWalkOrRunList.get(day2.get(temp)).getStepNumer();
                }
            }

            //得到3天前的步数
            int walkNum3=0;
            if (day3.size()!=0){
                System.out.println("3天前有："+day3.size());
                for (int temp=0;temp<day3.size();temp++){
                    walkNum3+=userWalkOrRunList.get(day3.get(temp)).getStepNumer();
                }
            }

            //得到4天前的步数
            int walkNum4=0;
            if (day4.size()!=0){
                System.out.println("4天前有："+day4.size());
                for (int temp=0;temp<day4.size();temp++){
                    walkNum4+=userWalkOrRunList.get(day4.get(temp)).getStepNumer();
                }
            }

            //得到5天前的步数
            int walkNum5=0;
            if (day5.size()!=0){
                System.out.println("5天前有："+day5.size());
                for (int temp=0;temp<day5.size();temp++){
                    walkNum5+=userWalkOrRunList.get(day5.get(temp)).getStepNumer();
                }
            }

            //得到6天前的步数
            int walkNum6=0;
            if (day6.size()!=0){
                System.out.println("6天前有："+day6.size());
                for (int temp=0;temp<day6.size();temp++){
                    walkNum6+=userWalkOrRunList.get(day6.get(temp)).getStepNumer();
                }
            }

            //填充记录并返回
            System.out.println("填充记录并返回");
            json_1_walkNum.setAveWalkNum(aveWalkNum);
            json_1_walkNum.setTotWalkNum(totalWalkNum);
            json_1_walkNum.setWalkNum0(walkNum0);
            json_1_walkNum.setWalkNum1(walkNum1);
            json_1_walkNum.setWalkNum2(walkNum2);
            json_1_walkNum.setWalkNum3(walkNum3);
            json_1_walkNum.setWalkNum4(walkNum4);
            json_1_walkNum.setWalkNum5(walkNum5);
            json_1_walkNum.setWalkNum6(walkNum6);
            json_1_walkNum.setResult(SportClientSymbol.Homepage.WALKNUM_RESULT_SUCCESS);

        }

        return json_1_walkNum;
    }



    //大卡的历史数据
    public Json_1_calorie calorie(Json_1_calorie json_1_calorie){

        System.out.println("进入Logic-1-calorie");

        //在运动历史表中先找出该用户所有的运动历史记录
        List<SporthistorytableEntity> userSportAllList=spoHisOperation.findSpoHisByUserId(logicUtils.findUser(json_1_calorie.getPhoneNumber()));

        //先判断该用户有没有运动历史的记录
        if(userSportAllList==null){
            //没有记录，用户大卡为0
            System.out.println("找不到运动历史大卡的记录");
            json_1_calorie.setAveCalorie(0.0f);
            json_1_calorie.setTotCalorie(0.0f);
            json_1_calorie.setCalorie0(0.0f);
            json_1_calorie.setCalorie1(0.0f);
            json_1_calorie.setCalorie2(0.0f);
            json_1_calorie.setCalorie3(0.0f);
            json_1_calorie.setCalorie4(0.0f);
            json_1_calorie.setCalorie5(0.0f);
            json_1_calorie.setCalorie6(0.0f);
            json_1_calorie.setResult(SportClientSymbol.Homepage.CALORIE_RESULT_SUCCESS_NULL);

        }else {
            //有记录就要计算出来各种大卡的数据
            System.out.println("找到运动历史的记录，一共有"+userSportAllList.size()+"条记录");

            //得到一周的时间，方便后续进行判断是哪一天的大卡
            DateInfo dateInfo=logicUtils.getWeekDateInfo();
            //先分好组，找到所有记录在最近一周的分布情况
            day0.clear();
            day1.clear();
            day2.clear();
            day3.clear();
            day4.clear();
            day5.clear();
            day6.clear();
            for (int temp=0;temp<userSportAllList.size();temp++){
                System.out.println(userSportAllList.get(temp).getId());
                //在今天內的归为今天，类似在那个时间段內的归为哪一天
                Timestamp timestamp=userSportAllList.get(temp).getStartTiem();
                if (timestamp.after(dateInfo.getToday_begin())&&timestamp.before(dateInfo.getToday_end())){
                    day0.add(temp);
                }else if (timestamp.after(dateInfo.getTodayBefore1_begin())&&timestamp.before(dateInfo.getTodayBefore1_end())){
                    day1.add(temp);
                }else if (timestamp.after(dateInfo.getTodayBefore2_begin())&&timestamp.before(dateInfo.getTodayBefore2_end())){
                    day2.add(temp);
                }else if (timestamp.after(dateInfo.getTodayBefore3_begin())&&timestamp.before(dateInfo.getTodayBefore3_end())){
                    day3.add(temp);
                }else if (timestamp.after(dateInfo.getTodayBefore4_begin())&&timestamp.before(dateInfo.getTodayBefore4_end())){
                    day4.add(temp);
                }else if (timestamp.after(dateInfo.getTodayBefore5_begin())&&timestamp.before(dateInfo.getTodayBefore5_end())){
                    day5.add(temp);
                }else if (timestamp.after(dateInfo.getTodayBefore6_begin())&&timestamp.before(dateInfo.getTodayBefore6_end())){
                    day6.add(temp);
                }
            }


            //得到总大卡
            Float totalCalorie=0.0f;
            for (int j=0;j<userSportAllList.size();j++){
                totalCalorie+=Float.parseFloat(String.valueOf(userSportAllList.get(j).getCalorie()));
            }

            //得到平均大卡
            Float aveCalorie=totalCalorie/userSportAllList.size();

            //得到今天的大卡
            Float calorie0=0.0f;
            if (day0.size()!=0){
                for (int temp=0;temp<day0.size();temp++){
                    calorie0+=Float.parseFloat(String.valueOf(userSportAllList.get(day0.get(temp)).getCalorie()));
                }
            }

            //得到1天前的大卡
            Float calorie1=0.0f;
            if (day1.size()!=0){
                for (int temp=0;temp<day1.size();temp++){
                    calorie1+=Float.parseFloat(String.valueOf(userSportAllList.get(day1.get(temp)).getCalorie()));
                }
            }

            //得到2天前的大卡
            Float calorie2=0.0f;
            if (day2.size()!=0){
                for (int temp=0;temp<day2.size();temp++){
                    calorie2+=Float.parseFloat(String.valueOf(userSportAllList.get(day2.get(temp)).getCalorie()));
                }
            }

            //得到3天前的大卡
            Float calorie3=0.0f;
            if (day3.size()!=0){
                for (int temp=0;temp<day3.size();temp++){
                    calorie3+=Float.parseFloat(String.valueOf(userSportAllList.get(day3.get(temp)).getCalorie()));
                }
            }

            //得到4天前的大卡
            Float calorie4=0.0f;
            if (day4.size()!=0){
                for (int temp=0;temp<day4.size();temp++){
                    calorie4+=Float.parseFloat(String.valueOf(userSportAllList.get(day4.get(temp)).getCalorie()));
                }
            }

            //得到5天前的大卡
            Float calorie5=0.0f;
            if (day5.size()!=0){
                for (int temp=0;temp<day5.size();temp++){
                    calorie5+=Float.parseFloat(String.valueOf(userSportAllList.get(day5.get(temp)).getCalorie()));
                }
            }

            //得到6天前的大卡
            Float calorie6=0.0f;
            if (day6.size()!=0){
                for (int temp=0;temp<day6.size();temp++){
                    calorie6+=Float.parseFloat(String.valueOf(userSportAllList.get(day6.get(temp)).getCalorie()));
                }
            }

            //填充记录并返回
            System.out.println("填充记录并返回");
            json_1_calorie.setAveCalorie(aveCalorie);
            json_1_calorie.setTotCalorie(totalCalorie);
            json_1_calorie.setCalorie0(calorie0);
            json_1_calorie.setCalorie1(calorie1);
            json_1_calorie.setCalorie2(calorie2);
            json_1_calorie.setCalorie3(calorie3);
            json_1_calorie.setCalorie4(calorie4);
            json_1_calorie.setCalorie5(calorie5);
            json_1_calorie.setCalorie6(calorie6);
            json_1_calorie.setResult(SportClientSymbol.Homepage.CALORIE_RESULT_SUCCESS);

        }

        return json_1_calorie;
    }




    //体重的历史数据
    public Json_1_weight weight(Json_1_weight json_1_weight){

        System.out.println("进入Logic-1-weight");


        //在个人身体素质历史表中先找出该用户所有的记录
        List<UserinfohistorytableEntity> userInfoAllList=userInfoHisOperation.findAllInfoHisByUserId(logicUtils.findUser(json_1_weight.getPhoneNumber()));

        //先判断该用户有没有个人身体素质历史的记录
        if(userInfoAllList==null){
            //没有记录，用户体重为0
            System.out.println("找不到个人身体素质历史的记录");
            json_1_weight.setAveWeight(0.0f);
            json_1_weight.setCurrentWeight(0.0f);
            json_1_weight.setWeight0(0.0f);
            json_1_weight.setWeight1(0.0f);
            json_1_weight.setWeight2(0.0f);
            json_1_weight.setWeight3(0.0f);
            json_1_weight.setWeight4(0.0f);
            json_1_weight.setWeight5(0.0f);
            json_1_weight.setWeight6(0.0f);
            json_1_weight.setResult(SportClientSymbol.Homepage.WEIGHT_RESULT_SUCCESS_NULL);

        }else {
            //有记录就要计算出来各种体重的数据
            System.out.println("找到个人身体素质历史的记录，一共有"+userInfoAllList.size()+"条记录");

            //得到一周的时间，方便后续进行判断是哪一天的体重
            DateInfo dateInfo=logicUtils.getMonthDateInfo();
            //先分好组，找到所有记录在最近一周的分布情况
            day0.clear();
            day1.clear();
            day2.clear();
            day3.clear();
            day4.clear();
            day5.clear();
            day6.clear();
            for (int temp=0;temp<userInfoAllList.size();temp++){
                System.out.println("在个人历史记录表中的id为："+userInfoAllList.get(temp).getId());
                //在这个月內的归为这个月，类似在哪个时间段內的归为哪一个月內
                Timestamp timestamp=userInfoAllList.get(temp).getTime();
                if (timestamp.after(dateInfo.getToday_begin())&&timestamp.before(dateInfo.getToday_end())){
                    day0.add(temp);
                }else if (timestamp.after(dateInfo.getTodayBefore1_begin())&&timestamp.before(dateInfo.getTodayBefore1_end())){
                    day1.add(temp);
                }else if (timestamp.after(dateInfo.getTodayBefore2_begin())&&timestamp.before(dateInfo.getTodayBefore2_end())){
                    day2.add(temp);
                }else if (timestamp.after(dateInfo.getTodayBefore3_begin())&&timestamp.before(dateInfo.getTodayBefore3_end())){
                    day3.add(temp);
                }else if (timestamp.after(dateInfo.getTodayBefore4_begin())&&timestamp.before(dateInfo.getTodayBefore4_end())){
                    day4.add(temp);
                }else if (timestamp.after(dateInfo.getTodayBefore5_begin())&&timestamp.before(dateInfo.getTodayBefore5_end())){
                    day5.add(temp);
                }else if (timestamp.after(dateInfo.getTodayBefore6_begin())&&timestamp.before(dateInfo.getTodayBefore6_end())){
                    day6.add(temp);
                }
            }


            //得到当前体重（采用最新的体重）
            Float currentWeight=0.0f;
            int index=0;
            for (int i = 0; i < userInfoAllList.size(); i++) {
                if (userInfoAllList.get(i).getTime().after(userInfoAllList.get(index).getTime())){
                    index=i;
                }
            }
            currentWeight=Float.parseFloat(String.valueOf(userInfoAllList.get(index).getWeight()));


            //得到平均体重
            Float totalWeight=0.0f;
            for (int j=0;j<userInfoAllList.size();j++){
                totalWeight+=Float.parseFloat(String.valueOf(userInfoAllList.get(j).getWeight()));
            }
            Float aveWeight=totalWeight/userInfoAllList.size();

            //得到这个月的平均体重
            Float weight0=0.0f;
            if (day0.size()!=0){
                for (int temp=0;temp<day0.size();temp++){
                    weight0+=Float.parseFloat(String.valueOf(userInfoAllList.get(day0.get(temp)).getWeight()));
                }
                weight0=weight0/day0.size();
            }

            //得到1个月前的平均体重
            Float weight1=0.0f;
            if (day1.size()!=0){
                for (int temp=0;temp<day1.size();temp++){
                    weight1+=Float.parseFloat(String.valueOf(userInfoAllList.get(day1.get(temp)).getWeight()));
                }
                weight1=weight1/day1.size();
            }

            //得到2个月前的平均体重
            Float weight2=0.0f;
            if (day2.size()!=0){
                for (int temp=0;temp<day2.size();temp++){
                    weight2+=Float.parseFloat(String.valueOf(userInfoAllList.get(day2.get(temp)).getWeight()));
                }
                weight2=weight2/day2.size();
            }

            //得到3个月前的平均体重
            Float weight3=0.0f;
            if (day3.size()!=0){
                for (int temp=0;temp<day3.size();temp++){
                    weight3+=Float.parseFloat(String.valueOf(userInfoAllList.get(day3.get(temp)).getWeight()));
                }
                weight3=weight3/day3.size();
            }

            //得到4个月前的平均体重
            Float weight4=0.0f;
            if (day4.size()!=0){
                for (int temp=0;temp<day4.size();temp++){
                    weight4+=Float.parseFloat(String.valueOf(userInfoAllList.get(day4.get(temp)).getWeight()));
                }
                weight4=weight4/day4.size();
            }

            //得到5个月前的平均体重
            Float weight5=0.0f;
            if (day5.size()!=0){
                for (int temp=0;temp<day5.size();temp++){
                    weight5+=Float.parseFloat(String.valueOf(userInfoAllList.get(day5.get(temp)).getWeight()));
                }
                weight5=weight5/day5.size();
            }

            //得到6个月前的平均体重
            Float weight6=0.0f;
            if (day6.size()!=0){
                for (int temp=0;temp<day6.size();temp++){
                    weight6+=Float.parseFloat(String.valueOf(userInfoAllList.get(day6.get(temp)).getWeight()));
                }
                weight6=weight6/day6.size();
            }

            //填充记录并返回
            System.out.println("填充记录并返回");
            json_1_weight.setAveWeight(aveWeight);
            json_1_weight.setCurrentWeight(currentWeight);
            json_1_weight.setWeight0(weight0);
            json_1_weight.setWeight1(weight1);
            json_1_weight.setWeight2(weight2);
            json_1_weight.setWeight3(weight3);
            json_1_weight.setWeight4(weight4);
            json_1_weight.setWeight5(weight5);
            json_1_weight.setWeight6(weight6);
            json_1_weight.setResult(SportClientSymbol.Homepage.WEIGHT_RESULT_SUCCESS);

        }


        return json_1_weight;
    }




    //公里数的历史数据
    public Json_1_kilometre kilometre(Json_1_kilometre json_1_kilometre){

        System.out.println("进入Logic-1-kilometre");


        //在运动历史表中先找出该用户所有的运动历史记录
        List<SporthistorytableEntity> userSportAllList=spoHisOperation.findSpoHisByUserId(logicUtils.findUser(json_1_kilometre.getPhoneNumber()));

        //先判断该用户有没有运动历史的记录
        if(userSportAllList==null){
            //没有记录，用户公里数为0
            System.out.println("找不到运动历史的记录");
            json_1_kilometre.setAveKilometre(0.0f);
            json_1_kilometre.setTotKilometre(0.0f);
            json_1_kilometre.setKilometre0(0.0f);
            json_1_kilometre.setKilometre1(0.0f);
            json_1_kilometre.setKilometre2(0.0f);
            json_1_kilometre.setKilometre3(0.0f);
            json_1_kilometre.setKilometre4(0.0f);
            json_1_kilometre.setKilometre5(0.0f);
            json_1_kilometre.setKilometre6(0.0f);
            json_1_kilometre.setResult(SportClientSymbol.Homepage.KILOMETRE_RESULT_SUCCESS_NULL);

        }else {
            //有记录就要计算出来各种公里数的数据
            System.out.println("找到运动历史公里数的记录，一共有"+userSportAllList.size()+"条记录");

            //得到一周的时间，方便后续进行判断是哪一天的公里数
            DateInfo dateInfo=logicUtils.getWeekDateInfo();
            //先分好组，找到所有记录在最近一周的分布情况
            day0.clear();
            day1.clear();
            day2.clear();
            day3.clear();
            day4.clear();
            day5.clear();
            day6.clear();
            for (int temp=0;temp<userSportAllList.size();temp++){
                System.out.println(userSportAllList.get(temp).getId());
                //在今天內的归为今天，类似在那个时间段內的归为哪一天
                Timestamp timestamp=userSportAllList.get(temp).getStartTiem();
                if (timestamp.after(dateInfo.getToday_begin())&&timestamp.before(dateInfo.getToday_end())){
                    day0.add(temp);
                }else if (timestamp.after(dateInfo.getTodayBefore1_begin())&&timestamp.before(dateInfo.getTodayBefore1_end())){
                    day1.add(temp);
                }else if (timestamp.after(dateInfo.getTodayBefore2_begin())&&timestamp.before(dateInfo.getTodayBefore2_end())){
                    day2.add(temp);
                }else if (timestamp.after(dateInfo.getTodayBefore3_begin())&&timestamp.before(dateInfo.getTodayBefore3_end())){
                    day3.add(temp);
                }else if (timestamp.after(dateInfo.getTodayBefore4_begin())&&timestamp.before(dateInfo.getTodayBefore4_end())){
                    day4.add(temp);
                }else if (timestamp.after(dateInfo.getTodayBefore5_begin())&&timestamp.before(dateInfo.getTodayBefore5_end())){
                    day5.add(temp);
                }else if (timestamp.after(dateInfo.getTodayBefore6_begin())&&timestamp.before(dateInfo.getTodayBefore6_end())){
                    day6.add(temp);
                }
            }


            //得到总公里数
            Float totalKilometre=0.0f;
            for (int j=0;j<userSportAllList.size();j++){
                totalKilometre+=Float.parseFloat(String.valueOf(userSportAllList.get(j).getSpoDis()));
            }

            //得到平均公里数
            Float aveKilometre=totalKilometre/userSportAllList.size();

            //得到今天的公里数
            Float kilometre0=0.0f;
            if (day0.size()!=0){
                for (int temp=0;temp<day0.size();temp++){
                    kilometre0+=Float.parseFloat(String.valueOf(userSportAllList.get(day0.get(temp)).getSpoDis()));
                }
            }

            //得到1天前的公里数
            Float kilometre1=0.0f;
            if (day1.size()!=0){
                for (int temp=0;temp<day1.size();temp++){
                    kilometre1+=Float.parseFloat(String.valueOf(userSportAllList.get(day1.get(temp)).getSpoDis()));
                }
            }

            //得到2天前的公里数
            Float kilometre2=0.0f;
            if (day2.size()!=0){
                for (int temp=0;temp<day2.size();temp++){
                    kilometre2+=Float.parseFloat(String.valueOf(userSportAllList.get(day2.get(temp)).getSpoDis()));
                }
            }

            //得到3天前的公里数
            Float kilometre3=0.0f;
            if (day3!=null){
                for (int temp=0;temp<day3.size();temp++){
                    kilometre3+=Float.parseFloat(String.valueOf(userSportAllList.get(day3.get(temp)).getSpoDis()));
                }
            }

            //得到4天前的公里数
            Float kilometre4=0.0f;
            if (day4.size()!=0){
                for (int temp=0;temp<day4.size();temp++){
                    kilometre4+=Float.parseFloat(String.valueOf(userSportAllList.get(day4.get(temp)).getSpoDis()));
                }
            }

            //得到5天前的公里数
            Float kilometre5=0.0f;
            if (day5.size()!=0){
                for (int temp=0;temp<day5.size();temp++){
                    kilometre5+=Float.parseFloat(String.valueOf(userSportAllList.get(day5.get(temp)).getSpoDis()));
                }
            }

            //得到6天前的公里数
            Float kilometre6=0.0f;
            if (day6.size()!=0){
                for (int temp=0;temp<day6.size();temp++){
                    kilometre6+=Float.parseFloat(String.valueOf(userSportAllList.get(day6.get(temp)).getSpoDis()));
                }
            }

            //填充记录并返回
            System.out.println("填充记录并返回");
            json_1_kilometre.setAveKilometre(aveKilometre);
            json_1_kilometre.setTotKilometre(totalKilometre);
            json_1_kilometre.setKilometre0(kilometre0);
            json_1_kilometre.setKilometre1(kilometre1);
            json_1_kilometre.setKilometre2(kilometre2);
            json_1_kilometre.setKilometre3(kilometre3);
            json_1_kilometre.setKilometre4(kilometre4);
            json_1_kilometre.setKilometre5(kilometre5);
            json_1_kilometre.setKilometre6(kilometre6);
            json_1_kilometre.setResult(SportClientSymbol.Homepage.KILOMETRE_RESULT_SUCCESS);

        }

        return json_1_kilometre;
    }


}
